<?php
/*
 * name: cxm
 * desc: 用户微信信息表
 * date: 2019/10/23
 * */
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class CreateUserWeixinTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_weixin', function (Blueprint $table) {
            $table->increments('id')->unsigned();
            $table->integer('user_id')->comment('用户ID');
            $table->char('openid')->nullable()->comment('用户的标识 对当前公众号唯一');
            $table->char('unionid')->nullable()->comment('用户的标识 对当前小程序唯一');
            $table->string('nickname')->nullable()->comment('用户昵称');
            $table->tinyInteger('sex')->comment('性别 1男2女');
            $table->char('city',50)->comment('用户所在城市');
            $table->char('province',50)->comment('用户所在省');
            $table->char('country',50)->comment('用户所在国家');
            $table->char('language',10)->comment('用户所用语言');
            $table->char('headimgurl',200)->comment('用户头像 最后一个数值代表正方形头像大小（有0、46、64、96、132数值可选，0代表640*640正方形头像），用户没有头像时该项为空。若用户更换头像，原有头像URL将失效。');
            $table->integer('sort')->comment('排序');
            $table->timestamps();
            $table->softDeletes();
        });
        // 表注释
        DB::statement("ALTER TABLE `".config('database.connections.mysql.prefix')."user_weixin` comment'用户微信表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_weixin');
    }
}
